

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>存储集群入门 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="块设备入门" href="../../../start/quick-rbd/" />
    <link rel="prev" title="飞前检查" href="../quick-start-preflight/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../">安装 Ceph</a> &raquo;</li>
        
          <li><a href="../">安装 (ceph-deploy)</a> &raquo;</li>
        
      <li>存储集群入门</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../../_sources/install/ceph-deploy/quick-ceph-deploy.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../">
          

          
            
            <img src="../../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../">安装 Ceph</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../#id1">建议的方法</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../#id2">其他方法</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../index_manual/">安装（手动）</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../">安装 (ceph-deploy)</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../quick-start-preflight/">Preflight</a></li>
<li class="toctree-l4 current"><a class="current reference internal" href="#">Storage Cluster Quick Start</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../start/quick-rbd/">Block Device Quick Start</a></li>
<li class="toctree-l4"><a class="reference internal" href="../quick-cephfs/">Filesystem Quick Start</a></li>
<li class="toctree-l4"><a class="reference internal" href="../quick-rgw/">Object Storage Quick Start</a></li>
<li class="toctree-l4"><a class="reference internal" href="../upgrading-ceph/">升级 Ceph</a></li>
<li class="toctree-l4"><a class="reference internal" href="../install-ceph-gateway/">    安装 Ceph 对象网关</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="id1">
<h1>存储集群入门<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>如果你还没完成<a class="reference external" href="../quick-start-preflight">飞前检查</a>，先做完。本篇<strong>入门</strong>用
<code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 从管理节点配置一个 <a class="reference internal" href="../../../glossary/#term-7"><span class="xref std std-term">Ceph 存储集群</span></a>，创建了一个三节点的集群，以此发掘 Ceph 功能。</p>
<p>第一次练习时，我们创建一个 Ceph 存储集群，它有一个监视器、三个
OSD 守护进程。一旦集群达到 <code class="docutils literal notranslate"><span class="pre">active</span> <span class="pre">+</span> <span class="pre">clean</span></code> 状态，再扩展它：增加第四个 OSD 、增加元数据服务器、和两个 Ceph 监视器。为获得最佳体验，先在管理节点上创建一个目录，用于保存 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code>
生成的配置文件和密钥对。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mkdir</span> <span class="n">my</span><span class="o">-</span><span class="n">cluster</span>
<span class="n">cd</span> <span class="n">my</span><span class="o">-</span><span class="n">cluster</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 会把文件输出到当前目录，所以执行的时候要先进入此目录。</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>不要用 <code class="docutils literal notranslate"><span class="pre">sudo</span></code> 或在另一普通用户下以 <code class="docutils literal notranslate"><span class="pre">root</span></code>
身份运行 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> ，因为它不能在远程主机上调用
<code class="docutils literal notranslate"><span class="pre">sudo</span></code> ，而 <code class="docutils literal notranslate"><span class="pre">root</span></code> 权限又是必需的。</p>
</div>
<div class="section" id="id2">
<h2>从头开始<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>如果在某些地方碰到麻烦，想从头再来，可以用下列命令清除 Ceph 软件包，并擦除所有数据和配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">purge</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}</span> <span class="p">[{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}]</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">purgedata</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}</span> <span class="p">[{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}]</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">forgetkeys</span>
<span class="n">rm</span> <span class="n">ceph</span><span class="o">.*</span>
</pre></div>
</div>
<p>如果执行了 <code class="docutils literal notranslate"><span class="pre">purge</span></code> ，你必须重新安装 Ceph 。最后的 <code class="docutils literal notranslate"><span class="pre">rm</span></code>
命令会删除之前 ceph-deploy 安装时写下的所有本地文件。</p>
</div>
<div class="section" id="id3">
<h2>创建一集群<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>在管理节点上，进入刚创建的放置配置文件的目录，用
<code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 执行如下步骤。</p>
<ol class="arabic">
<li><p>创建集群。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">new</span> <span class="p">{</span><span class="n">initial</span><span class="o">-</span><span class="n">monitor</span><span class="o">-</span><span class="n">node</span><span class="p">(</span><span class="n">s</span><span class="p">)}</span>
</pre></div>
</div>
<p>用主机名、 FQDN 或 hostname:fqdn 做节点名，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">new</span> <span class="n">node1</span>
</pre></div>
</div>
<p>用 <code class="docutils literal notranslate"><span class="pre">ls</span></code> 和 <code class="docutils literal notranslate"><span class="pre">cat</span></code> 检查 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 的输出，应该有新集群的一个 Ceph 配置文件（ <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> ）、一个监视器密钥环（ <code class="docutils literal notranslate"><span class="pre">ceph.mon.keyring</span></code> ）、和一个日志文件。详情见
<a class="reference external" href="../../../rados/deployment/ceph-deploy-new">ceph-deploy new -h</a> 。</p>
</li>
<li><p>如果你有多个网卡，可以把 <code class="docutils literal notranslate"><span class="pre">public</span> <span class="pre">network</span></code> 写入 Ceph 配置文件的 <code class="docutils literal notranslate"><span class="pre">[global]</span></code> 段下。详情见<a class="reference external" href="../../../rados/configuration/network-config-ref">网络配置参考</a>。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">bits</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="mf">10.1.2.0</span><span class="o">/</span><span class="mi">24</span>
</pre></div>
</div>
<p>使用 10.1.2.0/24 （或 10.1.2.0/255.255.255.0 ）网段内的
IP 地址。</p>
</li>
<li><p>如果你要在 IPv6 环境中部署，把下面的写入本地目录里的
<code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">echo</span> <span class="n">ms</span> <span class="n">bind</span> <span class="n">ipv6</span> <span class="o">=</span> <span class="n">true</span> <span class="o">&gt;&gt;</span> <span class="n">ceph</span><span class="o">.</span><span class="n">conf</span>
</pre></div>
</div>
</li>
<li><p>安装 Ceph 软件包。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">install</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">install</span> <span class="n">node1</span> <span class="n">node2</span> <span class="n">node3</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 会在各节点安装 Ceph 。</p>
</li>
<li><p>配置初始监视器、并收集所有密钥：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mon</span> <span class="n">create</span><span class="o">-</span><span class="n">initial</span>
</pre></div>
</div>
<p>完成上述操作后，当前目录里应该会出现这些密钥环：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.client.admin.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-mgr.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-osd.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-mds.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-rgw.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-rbd.keyring</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.bootstrap-rbd-mirror.keyring</span></code></p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果这里失败了，提示消息类似
“Unable to find /etc/ceph/ceph.client.admin.keyring” ，需核实 ceph.conf 里的监视器节点的 IP 地址，应该是公网 IP 而非私网 IP 。</p>
</div>
</li>
<li><p>用 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 把配置文件和 admin 密钥拷贝到管理节点、和各 Ceph 节点，这样你每次执行 Ceph 命令行时就无需指定监视器地址和 <code class="docutils literal notranslate"><span class="pre">ceph.client.admin.keyring</span></code> 了。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">admin</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">(</span><span class="n">s</span><span class="p">)}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">admin</span> <span class="n">node1</span> <span class="n">node2</span> <span class="n">node3</span>
</pre></div>
</div>
</li>
<li><p>部署一个管理器守护进程（ luminous 12.x 及其以上版本必须有）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mgr</span> <span class="n">create</span> <span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>添加三个 OSD 。为符合下列命令，我们假设各节点上都有一个未使用的磁盘名为 <code class="docutils literal notranslate"><span class="pre">/dev/vdb</span></code> 。<em>请确保这些设备当前没在使用，且其内没有重要数据。</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">osd</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="p">{</span><span class="n">device</span><span class="p">}</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">osd</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">vdb</span> <span class="n">node1</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">osd</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">vdb</span> <span class="n">node2</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">osd</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">vdb</span> <span class="n">node3</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果你在 LVM 卷上创建 OSD ，那么 <code class="docutils literal notranslate"><span class="pre">--data</span></code> 的参数<em>必须</em>是 <code class="docutils literal notranslate"><span class="pre">volume_group/lv_name</span></code> 格式，而不是逻辑卷的路径。</p>
</div>
</li>
<li><p>检查集群健康状况。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">node1</span> <span class="n">sudo</span> <span class="n">ceph</span> <span class="n">health</span>
</pre></div>
</div>
<p>集群应该会显示 <code class="docutils literal notranslate"><span class="pre">HEALTH_OK</span></code> 。更完整的集群状态可以用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">node1</span> <span class="n">sudo</span> <span class="n">ceph</span> <span class="o">-</span><span class="n">s</span>
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="id4">
<h2>运营集群<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>用 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 部署完成后它会自动启动集群。要在 Debian/Ubuntu 发行版下操作集群守护进程，参见<a class="reference external" href="../../../rados/operations/operating#running-ceph-with-upstart">用 upstart 控制 Ceph</a> ；要在 CentOS 、 Red Hat 、 Fedora 和 SLES 下操作集群守护进程，参见<a class="reference external" href="../../../rados/operations/operating#running-ceph-with-sysvinit">通过 sysvinit 机制运行 Ceph</a> 。</p>
<p>关于互联和集群健康状况请参见<a class="reference external" href="../../../rados/operations/monitoring">监控集群</a>；关于 OSD 守护进程和归置组健康状况参见<a class="reference external" href="../../../rados/operations/monitoring-osd-pg">监控 OSD 和归置组</a>；关于用户管理请参见<a class="reference external" href="../../../rados/operations/user-management">用户管理</a>。</p>
<p>Ceph 集群部署完成后，你可以尝试一下管理功能、 <code class="docutils literal notranslate"><span class="pre">rados</span></code> 对象存储命令，之后可以继续快速入门手册，了解 Ceph 块设备、 Ceph 文件系统和 Ceph 对象网关。</p>
</div>
<div class="section" id="id5">
<h2>扩展集群（扩容）<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<p>一个基本的集群启动并开始运行后，下一步就是扩展集群。在
<code class="docutils literal notranslate"><span class="pre">node1</span></code> 上添加一个元数据服务器；然后分别在 <code class="docutils literal notranslate"><span class="pre">node2</span></code> 和
<code class="docutils literal notranslate"><span class="pre">node3</span></code> 上添加 Ceph 监视器和 Ceph 管理器，以提高可靠性和可用性。</p>
<div class="section" id="id6">
<h3>添加元数据服务器<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3>
<p>至少有一个元数据服务器才能使用 CephFS ，执行下列命令创建元数据服务器：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mds</span> <span class="n">create</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">node</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mds</span> <span class="n">create</span> <span class="n">node1</span>
</pre></div>
</div>
</div>
<div class="section" id="id7">
<h3>添加监视器<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
<p>Ceph 存储集群需要至少一个 Ceph 监视器和 Ceph 管理器才能运行。为达到高可用性，典型的 Ceph 存储集群都需要运行多个监视器，这样在单个监视器失败时不会导致 Ceph 存储集群宕机。它用
Paxos 算法，此算法要求有过半监视器（即大于 <em>N/2</em> ， <em>N</em> 是监视器数量 ）才能形成法定人数。最好是奇数个监视器，虽然没强调。</p>
<p>新增两个监视器到集群：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mon</span> <span class="n">add</span> <span class="p">{</span><span class="n">ceph</span><span class="o">-</span><span class="n">nodes</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mon</span> <span class="n">add</span> <span class="n">node2</span> <span class="n">node3</span>
</pre></div>
</div>
<p>新增监视器后，它会自动开始同步、并形成法定人数。你可以用下面的命令检查法定人数状态：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">quorum_status</span> <span class="o">--</span><span class="nb">format</span> <span class="n">json</span><span class="o">-</span><span class="n">pretty</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>当你的 Ceph 集群运行着多个监视器时，各监视器主机上都<strong>应该</strong>配置 NTP ，而且要确保这些监视器位于 NTP 服务的同一级。</p>
</div>
</div>
<div class="section" id="id8">
<h3>添加管理器<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h3>
<p>Ceph 管理器守护进程以活跃/备用模式运作。多部署几个管理器守护进程可确保在一个守护进程或主机失效时，另一个可以即时接管而不中断服务。</p>
<p>用下列命令部署额外管理器守护进程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">mgr</span> <span class="n">create</span> <span class="n">node2</span> <span class="n">node3</span>
</pre></div>
</div>
<p>下列命令的输出里应该可以看到备用管理器了：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">node1</span> <span class="n">sudo</span> <span class="n">ceph</span> <span class="o">-</span><span class="n">s</span>
</pre></div>
</div>
</div>
<div class="section" id="rgw">
<h3>添加 RGW 例程<a class="headerlink" href="#rgw" title="Permalink to this headline">¶</a></h3>
<p>要使用 Ceph 的 <a class="reference internal" href="../../../glossary/#term-14"><span class="xref std std-term">Ceph 对象网关</span></a>组件，必须部署
<a class="reference internal" href="../../../glossary/#term-RGW"><span class="xref std std-term">RGW</span></a> 例程。用下列方法创建新 RGW 例程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">rgw</span> <span class="n">create</span> <span class="p">{</span><span class="n">gateway</span><span class="o">-</span><span class="n">node</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">rgw</span> <span class="n">create</span> <span class="n">node1</span>
</pre></div>
</div>
<p><a class="reference internal" href="../../../glossary/#term-RGW"><span class="xref std std-term">RGW</span></a> 例程默认会监听 7480 端口，可以更改 ceph.conf 内与此 <a class="reference internal" href="../../../glossary/#term-RGW"><span class="xref std std-term">RGW</span></a> 相关的配置，如下：</p>
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[client]</span>
<span class="na">rgw frontends</span> <span class="o">=</span> <span class="s">civetweb port=80</span>
</pre></div>
</div>
<p>用的是 IPv6 地址的话：</p>
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[client]</span>
<span class="na">rgw frontends</span> <span class="o">=</span> <span class="s">civetweb port=[::]:80</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="id9">
<h2>存入/检出对象数据<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h2>
<p>要把对象存入 Ceph 存储集群，客户端必须做到：</p>
<ol class="arabic simple">
<li><p>指定对象名</p></li>
<li><p>指定<a class="reference external" href="../../../rados/operations/pools">存储池</a></p></li>
</ol>
<p>Ceph 客户端检出最新的集群运行图，客户端用 CRUSH 算法动态地计算出如何把对象映射到<a class="reference external" href="../../../rados/operations/placement-groups">归置组</a>、然后计算如何把归置组分配到
OSD 。要定位对象，只需要对象名和存储池名字即可，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="nb">map</span> <span class="p">{</span><span class="n">poolname</span><span class="p">}</span> <span class="p">{</span><span class="nb">object</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<div class="topic">
<p class="topic-title">练习：定位某个对象</p>
<p>作为练习，我们先创建一个对象，用 <code class="docutils literal notranslate"><span class="pre">rados</span> <span class="pre">put</span></code> 命令加上对象名、一个有数据的测试文件路径、并指定存储池。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">echo</span> <span class="p">{</span><span class="n">Test</span><span class="o">-</span><span class="n">data</span><span class="p">}</span> <span class="o">&gt;</span> <span class="n">testfile</span><span class="o">.</span><span class="n">txt</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="n">create</span> <span class="n">mytest</span>
<span class="n">rados</span> <span class="n">put</span> <span class="p">{</span><span class="nb">object</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">file</span><span class="o">-</span><span class="n">path</span><span class="p">}</span> <span class="o">--</span><span class="n">pool</span><span class="o">=</span><span class="n">mytest</span>
<span class="n">rados</span> <span class="n">put</span> <span class="n">test</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="mi">1</span> <span class="n">testfile</span><span class="o">.</span><span class="n">txt</span> <span class="o">--</span><span class="n">pool</span><span class="o">=</span><span class="n">mytest</span>
</pre></div>
</div>
<p>为确认 Ceph 存储集群存储了此对象，这样确认：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rados</span> <span class="o">-</span><span class="n">p</span> <span class="n">mytest</span> <span class="n">ls</span>
</pre></div>
</div>
<p>现在，定位对象：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="nb">map</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="nb">object</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="nb">map</span> <span class="n">mytest</span> <span class="n">test</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="mi">1</span>
</pre></div>
</div>
<p>Ceph 应该会输出对象位置，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">osdmap</span> <span class="n">e537</span> <span class="n">pool</span> <span class="s1">&#39;mytest&#39;</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="nb">object</span> <span class="s1">&#39;test-object-1&#39;</span> <span class="o">-&gt;</span> <span class="n">pg</span> <span class="mf">1.</span><span class="n">d1743484</span> <span class="p">(</span><span class="mf">1.4</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">up</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="n">acting</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">rados</span> <span class="pre">rm</span></code> 可删除此测试对象。</p>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rados</span> <span class="n">rm</span> <span class="n">test</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="mi">1</span> <span class="o">--</span><span class="n">pool</span><span class="o">=</span><span class="n">mytest</span>
</pre></div>
</div>
<p>删除存储池 <code class="docutils literal notranslate"><span class="pre">mytest</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="n">rm</span> <span class="n">mytest</span>
</pre></div>
</div>
<p>（为安全起见，你需要额外加上提示的参数才能删掉存储池。删除存储池会销毁数据。）</p>
</div>
<p>随着集群的运行，对象位置可能会动态改变。 Ceph 动态均衡机制的好处之一是，把你从数据迁移和手动均衡中解放出来。</p>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../../../start/quick-rbd/" class="btn btn-neutral float-right" title="块设备入门" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../quick-start-preflight/" class="btn btn-neutral float-left" title="飞前检查" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>